// import fs from 'fs';
// import path from 'path';
import { getSequelize } from '../db';

import './app-parameter-name';
import './app-parameter-values';
import './language';
import './continent';
import './country';
import './state';
import './hotel';
import './user';
import './sys-menu';
import './user-permission';
import './user-hotel';
import './open-user';
import './sms-captcha';
import './room-type';
import './room-floor';
import './room-feature';
import './room';
import './room-room-feature';
import './deposit-rule';
import './reservation-prepay';
import './reservation-refund';
import './room-history';
import './weixin-access-token';
import './sms-sign';
import './sms-template';
import './sms-log';
import './mini-access-log';
import './mini-ticket';
import './mini-url';

const sequelize = getSequelize();

// fs.readdirSync(__dirname)
//   .filter((file) => /\.js$/.test(file) && file !== basename)
//   .forEach((file) => {
//     const model = require(path.join(__dirname, file)).default;
//     db[model.name] = model;
//   });

// sequelize.sync({ alter: true });
// sequelize.models.MemberTypes.sync({ alter: true });
// sequelize.models.MemberLevels.sync({ alter: true });
// sequelize.models.AppParameterNames.sync({ alter: true });
// sequelize.models.AppParameterValues.sync({ alter: true });
// sequelize.models.TransactionCodes.sync({ alter: true });
// sequelize.models.TransactionDetails.sync({ alter: true });
// sequelize.models.SysMenus.sync({ alter: true });
// sequelize.models.Users.sync({ alter: true });
// sequelize.models.MemberCardLogs.sync({ alter: true });
// sequelize.models.UserPermissions.sync({ alter: true });
// sequelize.models.AppParameterValues.sync({ alter: true });
// sequelize.models.MemberCards.sync({ alter: true });
// sequelize.models.PrintTemplates.sync({ alter: true });
// sequelize.models.PrintTemplateItems.sync({ alter: true });
// sequelize.models.UserOutlets.sync({ alter: true });
// sequelize.models.UserTransactionCodes.sync({ alter: true });
// sequelize.models.HMemberTypes.sync({ alter: true });
// sequelize.models.HMemberTypes.sync({ force: true }); // 删除表重建
// sequelize.models.OpenUsers.sync({ force: true }); // 删除表重建
// sequelize.models.SMSCaptcha.sync({ force: true }); // 删除表重建
// sequelize.models.HMemberCards.sync({ force: true }); // 删除表重建
// sequelize.models.HMemberCardTransactions.sync({ alter: true }); // 删除表重建
// sequelize.models.WeixinStableTokens.sync({ force: true }); // 删除表重建
// sequelize.models.MemberTypeOutlets.sync({ alter: true }); 
// sequelize.models.RoomType.sync({ alter: true });
// sequelize.models.RoomFloor.sync({ alter: true });
// sequelize.models.RoomFeature.sync({ alter: true });
// sequelize.models.Room.sync({ alter: true });
// sequelize.models.RoomRoomFeature.sync({ force: true });
// sequelize.models.DepositRule.sync({ force: true });
// sequelize.models.ReservationPrepay.sync({ force: true });
// sequelize.models.ReservationRefund.sync({ force: true });
// sequelize.models.RoomHistory.sync({ force: true });
// sequelize.models.SmsSign.sync({ force: true });
// sequelize.models.SmsTemplate.sync({ force: true });
// sequelize.models.SmsLog.sync({ force: true });
// sequelize.models.MiniAccessLog.sync({ force: true });
// sequelize.models.MiniTicket.sync({ force: true });
// sequelize.models.MiniUrl.sync({ force: true });

// console.log(sequelize.models);

const db = sequelize.models;
Object.keys(db).forEach((modelName) => {
  if (db[modelName].associate) {
    db[modelName].associate(db);
  }
});
